<template>
  <div>
    <div v-show="type == 'first'">
      <FilterTable
        ref="firsttable"
        :fetchapi="fetchApi1"
        :columns="columns1"
        :datakey="'rows'"
        :onColumnsChange="columns1 => (this.columns1 = columns1)"
        :height="130"
        columnsRef="zjwxlsoemSettlementTables1"
      ></FilterTable>
    </div>
    <div v-show="type == 'second'">
      <FilterTable
        ref="secondtable"
        :columns="columns2"
        :fetchapi="fetchApi2"
        :params="fetchParams2"
        :datakey="'records'"
        :onColumnsChange="columns2 => (this.columns2 = columns2)"
        :height="130"
        columnsRef="zjwxlsoemSettlementTables2"
      ></FilterTable>
    </div>
    <div v-show="type == 'third'">
      <FilterTable
        ref="thirdtable"
        :columns="columns3"
        :dataSource="list3"
        :params="fetchParams3"
        :datakey="'records'"
        :onColumnsChange="columns3 => (this.columns3 = columns3)"
        :height="130"
        columnsRef="zjwxlsoemSettlementTables3"
      ></FilterTable>
    </div>
    <div v-show="type == 'fourth'">
      <FilterTable
        ref="fourthtable"
        :columns="columns4"
        :params="fetchParams4"
        :dataSource="list4"
        :datakey="'records'"
        :onColumnsChange="columns4 => (this.columns4 = columns4)"
        :height="130"
        columnsRef="zjwxlsoemSettlementTables4"
      ></FilterTable>
    </div>
    <BaseDialog :visible.sync="exchangingVisible" title="派工情况" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <exchanging @close="closepop"></exchanging>
    </BaseDialog>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import exchanging from './exchanging.vue';
import { getoemQueryComplaint, getoemmaintainMaterialOEM, getoemSellMaterialOEM, getoemAccessoryOEM } from '@/api/repair/business/customer/history';
export default {
  name: 'zjoemsettlementTables',
  components: {
    exchanging
  },
  mixins: [dictionary],
  props: ['getdata', 'type'],
  data() {
    this.firsttable = null;
    this.secondtable = null;
    this.thirdtable = null;
    this.fourthtable = null;
    return {
      fetchParams1: {
        sort: 'RO_NO',
        order: 'asc',
        limit: '5',
        offset: '0',
        dealerCode: 'CK180101',
        maintain_material: '',
        dmsFuncId: '35100010',
        _: '1565592518126',
        RO_NO: this.getdata.RO_NO,
        ASC_SHORTNAME: this.getdata.ASC_SHORTNAME
      },
      fetchParams2: {},
      fetchParams3: {},
      fetchParams4: {},
      columns1: this.createTable1(),
      columns2: this.createTable2(),
      columns3: this.createTable3(),
      columns4: this.createTable4(),
      fetchApi1: getoemQueryComplaint,
      fetchApi2: getoemQueryComplaint,
      fetchApi3: getoemQueryComplaint,
      fetchApi4: getoemQueryComplaint,
      list1: [],
      list2: [],
      list3: [],
      list4: [],
      exchangingVisible: false
    };
  },
  created() {
    this.getlist();
  },
  methods: {
    createTable1() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '收费类别',
          dataIndex: 'MANAGE_SORT_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.MANAGE_SORT_CODE}</span>;
          }
        },
        {
          title: '收费区分',
          dataIndex: 'CHARGE_PARTITION_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.CHARGE_PARTITION_NAME}</span>;
          }
        },
        {
          title: '维修类型',
          dataIndex: 'REPAIR_TYPE_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.REPAIR_TYPE_NAME}</span>;
          }
        },
        {
          title: '故障原因',
          dataIndex: 'TROUBLE_CAUSE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.TROUBLE_CAUSE}</span>;
          }
        },
        {
          title: '维修项目代码',
          dataIndex: 'LABOUR_CODEF',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.LABOUR_CODEF}</span>;
          }
        },
        {
          title: '维修项目名称',
          dataIndex: 'LABOUR_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.LABOUR_NAME}</span>;
          }
        },
        {
          title: '组合代码',
          dataIndex: 'PACKAGE_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.PACKAGE_CODE}</span>;
          }
        },
        {
          title: '维修车型分组代码',
          dataIndex: 'MODEL_LABOUR_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.MODEL_LABOUR_CODE}</span>;
          }
        },
        {
          title: '工时单价',
          dataIndex: 'LABOUR_PRICE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.LABOUR_PRICE}</span>;
          }
        },
        {
          title: '标准工时',
          dataIndex: 'STD_LABOUR_HOUR',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.STD_LABOUR_HOUR}</span>;
          }
        },
        {
          title: '工时费',
          dataIndex: 'LABOUR_AMOUNT',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.LABOUR_AMOUNT}</span>;
          }
        },
        {
          title: '派工工时',
          dataIndex: 'ASSIGN_LABOUR_HOUR',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ASSIGN_LABOUR_HOUR}</span>;
          }
        },
        {
          title: '优惠金额',
          dataIndex: 'DISCOUNT_AMOUNT',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.DISCOUNT_AMOUNT}</span>;
          }
        },
        {
          title: '折旧率',
          dataIndex: 'DISCOUNT',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.DISCOUNT}</span>;
          }
        },
        {
          title: '实收金额',
          dataIndex: 'RECEIVE_AMOUNT',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.RECEIVE_AMOUNT}</span>;
          }
        },
        {
          title: '工种',
          dataIndex: 'WORKER_TYPE_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.WORKER_TYPE_CODE}</span>;
          }
        },
        {
          title: '派工标志',
          dataIndex: 'ASSIGN_TAG',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.ASSIGN_TAG, '1278')}</span>;
          }
        },
        {
          title: '是否委外',
          dataIndex: 'CONSIGN_EXTERIOR',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.CONSIGN_EXTERIOR, '1278')}</span>;
          }
        },
        {
          title: '是否不修',
          dataIndex: 'NEEDLESS_REPAIR',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.NEEDLESS_REPAIR, '1278')}</span>;
          }
        },
        {
          title: '责任技师',
          dataIndex: 'TECHNICIAN_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.TECHNICIAN_NAME, '1278')}</span>;
          }
        },
        {
          title: '是否预检',
          dataIndex: 'PRE_CHECK',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.PRE_CHECK, '1278')}</span>;
          }
        },
        {
          title: '是否内返',
          dataIndex: 'INTER_RETURN',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.INTER_RETURN, '1278')}</span>;
          }
        },
        {
          title: '活动编号',
          dataIndex: 'ACTIVITY_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ACTIVITY_CODE}</span>;
          }
        },
        {
          title: '检查结果',
          dataIndex: 'TROUBLE_DESC',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.TROUBLE_DESC}</span>;
          }
        },
        {
          title: '备注',
          dataIndex: 'REMARK',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.REMARK}</span>;
          }
        }
      ];
    },
    createTable2() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '收费类别',
          dataIndex: 'MANAGE_SORT_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.MANAGE_SORT_CODE}</span>;
          }
        },
        {
          title: '收费区分',
          dataIndex: 'CHARGE_PARTITION_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.CHARGE_PARTITION_NAME}</span>;
          }
        },
        {
          title: '维修类型',
          dataIndex: 'REPAIR_TYPE_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.REPAIR_TYPE_NAME}</span>;
          }
        },
        {
          title: '故障原因',
          dataIndex: 'TROUBLE_CAUSE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.TROUBLE_CAUSE}</span>;
          }
        },
        {
          title: '维修项目代码',
          dataIndex: 'LABOUR_CODEF',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.LABOUR_CODEF}</span>;
          }
        },
        {
          title: '维修项目名称',
          dataIndex: 'LABOUR_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.LABOUR_NAME}</span>;
          }
        },
        {
          title: '组合代码',
          dataIndex: 'PACKAGE_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.PACKAGE_CODE}</span>;
          }
        },
        {
          title: '维修车型分组代码',
          dataIndex: 'MODEL_LABOUR_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.MODEL_LABOUR_CODE}</span>;
          }
        },
        {
          title: '工时单价',
          dataIndex: 'LABOUR_PRICE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.LABOUR_PRICE}</span>;
          }
        },
        {
          title: '标准工时',
          dataIndex: 'STD_LABOUR_HOUR',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.STD_LABOUR_HOUR}</span>;
          }
        },
        {
          title: '工时费',
          dataIndex: 'LABOUR_AMOUNT',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.LABOUR_AMOUNT}</span>;
          }
        },
        {
          title: '派工工时',
          dataIndex: 'ASSIGN_LABOUR_HOUR',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ASSIGN_LABOUR_HOUR}</span>;
          }
        },
        {
          title: '优惠金额',
          dataIndex: 'DISCOUNT_AMOUNT',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.DISCOUNT_AMOUNT}</span>;
          }
        },
        {
          title: '折旧率',
          dataIndex: 'DISCOUNT',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.DISCOUNT}</span>;
          }
        },
        {
          title: '实收金额',
          dataIndex: 'RECEIVE_AMOUNT',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.RECEIVE_AMOUNT}</span>;
          }
        },
        {
          title: '工种',
          dataIndex: 'WORKER_TYPE_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.WORKER_TYPE_CODE}</span>;
          }
        },
        {
          title: '派工标志',
          dataIndex: 'ASSIGN_TAG',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.ASSIGN_TAG, '1278')}</span>;
          }
        },
        {
          title: '是否委外',
          dataIndex: 'CONSIGN_EXTERIOR',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.CONSIGN_EXTERIOR, '1278')}</span>;
          }
        },
        {
          title: '是否不修',
          dataIndex: 'NEEDLESS_REPAIR',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.NEEDLESS_REPAIR, '1278')}</span>;
          }
        },
        {
          title: '责任技师',
          dataIndex: 'TECHNICIAN_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.TECHNICIAN_NAME, '1278')}</span>;
          }
        },
        {
          title: '是否预检',
          dataIndex: 'PRE_CHECK',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.PRE_CHECK, '1278')}</span>;
          }
        },
        {
          title: '是否内返',
          dataIndex: 'INTER_RETURN',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.INTER_RETURN, '1278')}</span>;
          }
        },
        {
          title: '活动编号',
          dataIndex: 'ACTIVITY_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ACTIVITY_CODE}</span>;
          }
        },
        {
          title: '检查结果',
          dataIndex: 'TROUBLE_DESC',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.TROUBLE_DESC}</span>;
          }
        },
        {
          title: '备注',
          dataIndex: 'REMARK',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.REMARK}</span>;
          }
        }
      ];
    },
    createTable3() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '收费类别',
          dataIndex: 'MANAGE_SORT_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.MANAGE_SORT_CODE}</span>;
          }
        },
        {
          title: '收费区分',
          dataIndex: 'CHARGE_PARTITION_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.CHARGE_PARTITION_CODE}</span>;
          }
        },
        {
          title: '仓库代码',
          dataIndex: 'STORAGE_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.STORAGE_CODE}</span>;
          }
        },
        {
          title: '备件代码',
          dataIndex: 'PART_NO',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.PART_NO}</span>;
          }
        },
        {
          title: '备件名称',
          dataIndex: 'PART_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.PART_NAME}</span>;
          }
        },
        {
          title: '计量单位',
          dataIndex: 'UNIT_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.UNIT_CODE}</span>;
          }
        },
        {
          title: '备件销售数量',
          dataIndex: 'PART_QUANTITY',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.PART_QUANTITY}</span>;
          }
        },
        {
          title: '是否入账',
          dataIndex: 'IS_FINISHED',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.IS_FINISHED, '1278')}</span>;
          }
        }
      ];
    },
    createTable4() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '收费类别',
          dataIndex: 'MANAGE_SORT_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.MANAGE_SORT_CODE}</span>;
          }
        },
        {
          title: '收费区分',
          dataIndex: 'CHARGE_PARTITION_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.CHARGE_PARTITION_NAME}</span>;
          }
        },
        {
          title: '附加项目代码',
          dataIndex: 'ADD_ITEM_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ADD_ITEM_CODE}</span>;
          }
        },
        {
          title: '附加项目名称',
          dataIndex: 'ADD_ITEM_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ADD_ITEM_NAME}</span>;
          }
        },
        {
          title: '备注',
          dataIndex: 'REMARK',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.REMARK}</span>;
          }
        }
      ];
    },
    async getlist() {
      let that = this;
      // that.list1 = (await getoemQueryComplaint(this.fetchParams1)).rows || [];
      // that.list2 = (await getoemmaintainMaterialOEM(this.fetchParams1)).rows || [];
      that.list4 = (await getoemAccessoryOEM(this.fetchParams1)).rows || [];
      console.log(that.list4);
      that.list3 = (await getoemSellMaterialOEM(this.fetchParams1)).rows || [];
      console.log(that.list3);
    },
    closepop(val) {
      this.exchangingVisible = false;
    }
  }
};
</script>
